package assdraw2.common;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBoxMenuItem;


public class WindowActionListener implements ActionListener{

	private PACAgent agent;
	private int id;
	
	public WindowActionListener(int id, PACAgent parent){
		super();
		this.id = id;
		agent = AgentFactory.getAgent(id, parent);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(((JCheckBoxMenuItem)e.getSource()).isSelected()){
			agent.receiveMessage(new PACMessage(MessageType.OPEN, id));
		}else{
			agent.receiveMessage(new PACMessage(MessageType.CLOSE, id));
		}
		
	}

	public PACAgent getAgent() {
		return agent;
	}
	

}
